<template>
  <el-row id="company-container"
          v-loading="controlDialogLoading"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.8)">
    <el-row v-if="!isViewShow" class="permission">
       没有权限!
    </el-row>

    <el-card v-else class="box-card">
      <div slot="header" class="clearfix">
        <span>数据看板</span>
        <el-button :disabled="!isViewEdit" @click="handlerHomeConfig" style="margin-right: 10px" type="primary">配置</el-button>
        <el-button :disabled="!isViewEdit" @click="handlerControl" style="margin-right: 8px" type="primary">控制</el-button>
        <el-button :disabled="!isViewEdit" @click="handlerSetting" style="margin-right: 0px" type="primary">系统参数</el-button>
        <el-button :disabled="!isViewEdit" @click="handlerCustom" style="margin-right: 0px" type="primary">自定义参数</el-button>
      </div>

      <el-row type="flex" class="box-card-content">
         <el-col v-for="item in userTags">
           <el-row type="flex">
             <i class="iconfont iconyuan"></i>
             <span>{{item.tagName}}</span>
           </el-row>
           <el-row type="flex">
             <span>{{item.value}}{{item.unit}}</span>
           </el-row>
           <el-row type="flex">
             <span>{{item.time}}</span>
           </el-row>
         </el-col>
      </el-row>
    </el-card>

    <!--控制弹窗-->
    <el-dialog  :visible.sync="controlDialogShow">
      <el-row slot="title">
        <span style="font-size: 18px">控制</span>
      </el-row>

      <el-row class="control-dialog-content">
        <el-row>
          <el-card class="box-card">
            <div slot="header" class="clearfix">
              <span>远程逻辑控制</span>
              <el-button @click="handlerLogicConfig" style="float: right; padding: 3px 0" type="text">配置</el-button>
            </div>
            <el-row class="logic-control" type="flex">
              <el-col v-for="item in controlTags.notUrgentList">
                  <el-row type="flex"><span>{{item.tagName}}</span></el-row>
                  <el-row type="flex" style="margin-top: 20px">
                    <!--v-model="switchFilter(item.inputValue)"-->
                    <el-switch
                      :value="switchFilter(item.inputValue)"
                      @change="onLogicChang($event,0,item)"
                      active-color="#13ce66"
                      inactive-color="#ff4949">
                    </el-switch>
                  </el-row>
              </el-col>
            </el-row>
          </el-card>
        </el-row>
        <el-row>
          <el-card class="box-card">
            <div slot="header" class="clearfix">
              <span>远程紧急控制</span>
              <el-button @click="handlerUrgencyConfig" style="float: right; padding: 3px 0" type="text">配置</el-button>
            </div>
            <el-row class="urgency-control" type="flex">
              <el-col v-for="item in controlTags.urgentList">
                <el-row type="flex"><span>{{item.tagName}}</span></el-row>
                <el-row type="flex" style="margin-top: 20px">
                  <el-select v-model="item.inputValue" placeholder="请选择" @change="onUrgencyChang($event,1,item)">
                    <el-option
                      v-for="item in urgencyOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                 <!-- <el-switch
                    :value="switchFilter(item.inputValue)"
                    @change="onUrgencyChang($event,1,item)"
                    active-color="#13ce66"
                    inactive-color="#ff4949">
                  </el-switch>-->
                </el-row>
              </el-col>
            </el-row>

          </el-card>
        </el-row>
      </el-row>
    </el-dialog>

    <!--系统参数弹窗-->
    <el-dialog :visible.sync="settingDialogShow">
      <el-row slot="title">
        <span style="font-size: 18px">参数设置</span>
        <el-button @click="handlerSettingConfig" style="margin-right: 30px; padding: 6px 10px" type="primary" :loading="false">配置</el-button>
      </el-row>

      <el-row class="setting-dialog-content">
        <el-row class="custom-layout" type="flex">
          <!--<el-col v-for="item in 40">
            <el-row type="flex"><span>标题</span></el-row>
            <el-row type="flex">
              <el-input v-model="item.inputValue" placeholder="请输入"></el-input>
              <span>&lt;!&ndash;{{item.unit}}&ndash;&gt;unit</span>
            </el-row>
            <el-row type="flex">
              <el-button @click="fixSettingTagValue(item)">确定</el-button>
            </el-row>
          </el-col>-->
          <el-col v-for="item in systemTags.notCustomizeList">
            <el-row type="flex"><span>{{item.tagName}}</span></el-row>
            <el-row type="flex">
              <el-input v-model="item.inputValue" placeholder="请输入"></el-input>
              <span>{{item.unit}}</span>
            </el-row>
            <el-row type="flex">
              <el-button @click="fixSettingTagValue(item)">确定</el-button>
            </el-row>
          </el-col>
        </el-row>
      </el-row>
    </el-dialog>

    <!--自定义参数弹窗-->
    <el-dialog :visible.sync="customDialogShow">
      <el-row slot="title">
        <span style="font-size: 18px">自定义</span>
        <!-- <el-button  @click="handlerCustomConfig" style="margin-right: 30px; padding: 6px 10px" type="primary" :loading="false">配置</el-button>-->
      </el-row>

      <el-row class="custom-dialog-content">
        <el-row class="custom-layout" type="flex">
         <!-- <el-col v-for="item in 40">
            <el-row type="flex"><span>标题</span></el-row>
            <el-row type="flex">
              <el-input v-model="item.inputValue" placeholder="请输入"></el-input>
            </el-row>
            <el-row type="flex">
              <el-button @click="fixCustomTag(item)">确定</el-button>
              <el-button @click="customBind(item)">绑定</el-button>
            </el-row>
          </el-col>-->
          <el-col v-for="item in systemTags.customizeList">
            <el-row type="flex"><span>{{item.inputName}}</span></el-row>
            <el-row type="flex">
              <el-input :disabled="!item.whetherUpdate" v-model="item.inputValue" placeholder="请输入"></el-input>
            </el-row>
            <el-row type="flex">
              <el-button :disabled="!item.whetherUpdate" @click="fixCustomTag(item)">确定</el-button>
               <el-button :disabled="item.fieldType | changeType" @click="customBind(item)">绑定</el-button>
            </el-row>
          </el-col>
        </el-row>
      </el-row>
    </el-dialog>

    <!--自定义新增弹窗-->
    <el-dialog :visible.sync="addDialogShow">
      <el-row slot="title">
        <span style="font-size: 18px">自定义配置</span>
      </el-row>

      <el-row class="add-dialog-content">
        <!-- <el-row type="flex">
           <el-input  v-model="addCustomForm.inputName" placeholder="请输入变量名"></el-input>
           <el-input  v-model="addCustomForm.inputValue" placeholder="请输入变量值"></el-input>
           <el-button @click="submitAddCustomValue" style="padding: 6px 20px" type="primary">确定</el-button>
         </el-row>-->
         <el-row>
           <el-table
             :data="systemTags.customizeList"
             style="width: 100%"
             header-align="center"
             max-height="520">
             <el-table-column
               prop="inputName"
               label="变量名">
             </el-table-column>
             <el-table-column
               prop="inputValue"
               label="变量值">
             </el-table-column>
            <!-- <el-table-column
               align="right"
               label="操作">
               <template slot-scope="scope">
                 <el-button
                   @click.native.prevent="deleteCustomTag(scope.row)"
                   type="text"
                   size="small">
                   移除
                 </el-button>
               </template>
             </el-table-column>-->
           </el-table>
         </el-row>
      </el-row>
    </el-dialog>

    <!--首页变量的配置-->
    <el-dialog :visible.sync="homeConfigDialogShow">
      <el-row slot="title" type="flex">
        <span style="font-size: 18px">变量点配置</span>
        <el-button @click="submitMult" style="margin-left: 1180px; padding: 6px 10px" type="primary" :loading="false">提交</el-button>
      </el-row>

      <el-row class="home-config-dialog-content">
        <el-row>
          <el-table
            ref="multipleTable"
            :data="homeTableDatas"
            @selection-change="handleSelectionChange"
            max-height="560"
            tooltip-effect="dark"
            style="width: 100%">
            <el-table-column
              type="selection"
              width="55">
            </el-table-column>
            <el-table-column
              prop="tagId"
              label="变量名">
            </el-table-column>
            <el-table-column
              prop="tagName"
              label="备注名">
            </el-table-column>
          </el-table>
        </el-row>
      </el-row>
    </el-dialog>

  </el-row>

</template>

<script>
  export default {
    name: "index",
    data() {
      return {
        isViewShow: false,
        isViewEdit: false,
        maxShowLength: 40,      // 首页最多展示参数
        systemShowLength: 40,   // 配置项最多展示参数
        /*弹窗*/
        customDialogShow: false,     // 首页控制弹窗
        controlDialogShow: false,     // 首页控制弹窗
        settingDialogShow: false,     // 首页设置弹窗
        homeConfigDialogShow: false,  // 首页配置弹窗
        addDialogShow: false,         // 自定义新增弹窗
        /*初始化数据*/
        settingType: 1,           // 1,主面板配置 2，系统参数配置 3，控制非紧急参数配置 4，控制紧急参数配置
        homeTableDatas:[],        //  首页配置,参数配置,控制配置
        changeMultStr: '',        //  配置新增多选的拼接值
        userTags: [],             //  首页数据看板的初始值
        systemTags: {             //  设置配置的初始值
          customizeList:[],
          notCustomizeList:[],
        },
        systemTagsAll:[],         //  参数配置的初始化选择值
        addCustomForm:{           //  新增自定义配置项的初始值
          inputValue: "",
          inputName: ""
        },
        controlTags: {            //  控制配置的初始值
          notUrgentList:[],
          urgentList:[]
        },
        urgencyOptions: [{value:2.0,label:'紧急关'},{value:1.0,label:'紧急开'},{value:0.0,label:'取消紧急'}],       //  紧急开关的选择项
        /*选择项数据*/
        selectItem: '',
        /*控制弹窗加载框*/
        controlDialogLoading:false
      }
    },
    created() {
      this.$emit('fixHeadIndex', "1")
      this.timer = setInterval(() =>{
        this.askList()
      },1000* 10)
    },
    beforeDestroy () {
      clearInterval(this.timer)
    },
    filters:{
      changeType: function(value) {    // 自定义参数是否可绑定
        return value === 0 ? true : false
      },

    },
    computed:{
      switchFilter: function(){
        return (inputValue) =>{
          return inputValue == 1 ? true : false
        }
      }
    },
    mounted() {
      let obj = this.validateGlobal.getPermission(1)
      this.isViewShow = obj.isViewShow
      this.isViewEdit = obj.isViewEdit
      this.askList()                // 首页数据看板列表
    },
    methods:{
      toggleSelection(rows) {
        let _that = this
        if (rows) {
          _that.$nextTick(()=>{
            rows.forEach(row => {
              _that.$refs.multipleTable.toggleRowSelection(row,true);
            });
          })
        } else {
          _that.$refs.multipleTable.clearSelection();
        }
      },
      /*公共的处理多选的结构*/
      handleSelectionChange: function(val){
        console.log("主面板的选择val:",val)
        this.changeMultStr = ''
        let _that = this
        if (val && val.length > 0) {
          if (val.length > _that.maxShowLength){
            this.$message("最多只能展示40条数据!")
          }
          let multStr = ''
          for(let i = 0;i< val.length;++i){
            if (val.length === 1){
              multStr += val[i].attributeId
            }else{
              if (i == val.length-1){
                multStr += val[i].attributeId
              }else{
                multStr += (val[i].attributeId+ ",")
              }
            }
          }
          _that.changeMultStr = multStr
        }
      },
      /*点击主面板自定义参数*/
      handlerCustom: function(){
        if (this.customDialogShow){
          this.customDialogShow = false
        } else{
          this.customDialogShow = true
        }
        this.settingType = 2
        this.askCustomTags()
      },
      handlerControl: function () {
        if (this.controlDialogShow){
          this.controlDialogShow = false
        } else{
          this.controlDialogShow = true
        }

        this.askMyControlTags()
      },
      handlerSetting: function () {
        if (this.settingDialogShow){
          this.settingDialogShow = false
        } else{
          this.settingDialogShow = true
        }
        this.settingType = 2
        this.askSystemTags()
      },
      handlerCustomConfig: function () {
      /*  if (this.addDialogShow){
          this.addDialogShow = false
        } else{
          this.addDialogShow = true
        }*/

        if (this.homeConfigDialogShow){
          this.homeConfigDialogShow = false
        } else{
          this.homeConfigDialogShow = true
        }
        this.askSystemTagsAll()
        // _that.homeTableDatas = res.data

      },
      handlerHomeConfig: function () {
        if (this.homeConfigDialogShow){
          this.homeConfigDialogShow = false
        } else{
          this.homeConfigDialogShow = true
        }
        this.settingType = 1
        this.askTagList()
      },
      handlerLogicConfig: function() {
        if (this.homeConfigDialogShow){
          this.homeConfigDialogShow = false
        } else{
          this.homeConfigDialogShow = true
        }
        this.settingType = 3
        this.askControlNotUrgentTagsAll()
      },
      handlerUrgencyConfig: function() {
        if (this.homeConfigDialogShow){
          this.homeConfigDialogShow = false
        } else{
          this.homeConfigDialogShow = true
        }
        this.settingType = 4
        this.askControlUrgentTagsAll()
      },
      handlerSettingConfig: function() {
        if (this.homeConfigDialogShow){
          this.homeConfigDialogShow = false
        } else{
          this.homeConfigDialogShow = true
        }
        this.askSystemTagsAll()

      },

      /*获取主面板的数据*/
      askList: function() {
        let _that = this
        let gateway = sessionStorage.getItem("gateway")
        let userId = sessionStorage.getItem("userId")
        let url = _that.ports.dataLook.home.list
        let askData = {
          userId: userId,
          sn: gateway
        }
        this.http.get(url,askData, res => {
          console.log("ourTagList",res)
          if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
            if (res.data.length > _that.maxShowLength){
              _that.userTags = res.data.slice(0,_that.maxShowLength)
            } else{
              _that.userTags = res.data
            }

          }else{
            _that.$message('列表获取失败!');
          }
        })
      },
      // 获取主面板配置下拉列表数据
      askTagList: function(){
        let _that = this
        let gateway = sessionStorage.getItem("gateway")
        let userId = sessionStorage.getItem("userId")
        let url = _that.ports.dataLook.settingList.mainBlockList
        let askData = {
          userId: userId,
          sn: gateway
        }
        this.http.get(url,askData, res => {
          console.log("tagList",res)
          if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
             _that.homeTableDatas = res.data
             let arry = []
             for(let i = 0;i<_that.homeTableDatas.length;++i){
               if (_that.homeTableDatas[i].whetherCheck) {
                 arry.push(_that.homeTableDatas[i])
               }
             }
             _that.toggleSelection(arry)
             // _that.askList()
          }else{
            _that.$message('列表获取失败!');
          }
        })
      },
      submitMult: function(){
        let _that = this
        /*主面板的配置新增*/
        if (this.settingType === 1) {
          let gateway = sessionStorage.getItem("gateway")
          let userId = sessionStorage.getItem("userId")
          let url = _that.ports.dataLook.home.add
          let askData = {
            userId: userId,
            sn: gateway,
            attributeIds: _that.changeMultStr
          }
          this.http.postForm(url,askData, res => {
            console.log("tagList",res)
            if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
              _that.homeConfigDialogShow = false
              _that.askList()
            }else{
              _that.$message('列表获取失败!');
            }
          })
        }
        /*设置面板的配置新增*/
        if (this.settingType === 2) {
          let gateway = sessionStorage.getItem("gateway")
          let url = _that.ports.dataLook.add.settingAdd
          let askData = {
            sn: gateway,
            attributeIds: _that.changeMultStr
          }
          this.http.postForm(url,askData, res => {
            console.log("tagList",res)
            if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
              _that.homeConfigDialogShow = false
              // _that.askList()
              _that.askSystemTags()
            }else{
              _that.$message('配置失败!');
            }
          })
        }
         /*控制面板的配置新增*/
        if (this.settingType === 3 || this.settingType === 4) {
          let gateway = sessionStorage.getItem("gateway")
          let userId = sessionStorage.getItem("userId")
          let url = _that.ports.dataLook.add.controlAdd
          let askData = {
            whetherUrgent: _that.settingType === 3 ? 0 : 1,
            sn: gateway,
            attributeIds: _that.changeMultStr
          }
          this.http.postForm(url,askData, res => {
            if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
              _that.homeConfigDialogShow = false
              _that.askMyControlTags()
            }else{
              _that.$message('配置失败!');
            }
          })
        }
        /* 自定义绑定修改配置*/
        if (this.settingType === 5){
          /*if (!_that.changeMultStr){
            return
          }*/
          if (this.selectItem.fieldType === 1 && _that.changeMultStr.split(',').length > 1) {
            this.$message("该参数只能绑定一个变量!")
            return
          }
          let gateway = sessionStorage.getItem("gateway")
          let url = _that.ports.dataLook.add.customAdd2
          let askData = {
            customizeId: _that.selectItem.customizeId,
            sn: gateway,
            attributeIds: _that.changeMultStr
          }
          this.http.postForm(url,askData, res => {
            if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
              _that.homeConfigDialogShow = false
              _that.askCustomTags()
            }else{
              _that.$message('配置失败!');
            }
          })
        }
        this.homeConfigDialogShow = false
      },
      askSystemTags: function() {
        let _that = this
        let gateway = sessionStorage.getItem("gateway")
        let url = _that.ports.dataLook.controlOrSetting.list
        let askData = {
          sn: gateway,
          type: 1
        }
        this.http.get(url,askData, res => {
          console.log("systemTagList",res)
          if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
            if (res.data.notCustomizeList && res.data.notCustomizeList.length>0){
              if (res.data.notCustomizeList.length > _that.systemShowLength) {
                 _that.systemTags.notCustomizeList = res.data.notCustomizeList.slice(0,_that.systemShowLength)
              }else{
                _that.systemTags.notCustomizeList = res.data.notCustomizeList
              }
            }
           /* if (res.data.customizeList && res.data.customizeList.length>0){
              if (res.data.customizeList.length > _that.systemShowLength) {
                _that.systemTags.customizeList = res.data.customizeList.slice(0,_that.systemShowLength)
              }else{
                _that.systemTags.customizeList = res.data.customizeList
              }
            }*/
          }else{
            _that.$message('列表获取失败!');
          }
        })
      },
      askCustomTags: function() {
        let _that = this
        let gateway = sessionStorage.getItem("gateway")
        let url = _that.ports.dataLook.myTags.customTags
        let askData = {
          sn: gateway,
        }
        this.http.get(url,askData, res => {
          console.log("customTags",res)
          if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
             if(res.data){
               _that.systemTags.customizeList = res.data
             }
          }else{
            _that.$message('列表获取失败!');
          }
        })
      },
      askCustomBindTags: function(){
        let _that = this
        let gateway = sessionStorage.getItem("gateway")
        let url = _that.ports.dataLook.bind.customBindTags
        let askData = {
          customizeId: _that.selectItem.customizeId,
          sn: gateway
        }
        this.http.get(url,askData, res => {
          console.log("customBindTags",res)
          if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
            if (res.data){
              _that.homeTableDatas = res.data
              let arry = []
              for(let i = 0;i<_that.homeTableDatas.length;++i){
                if (_that.homeTableDatas[i].whetherCheck) {
                  arry.push(_that.homeTableDatas[i])
                }
              }
              _that.toggleSelection(arry)
            }
          }else{
            _that.$message('列表获取失败!');
          }
        })
      },
      askSystemTagsAll: function() {
        let _that = this
        let gateway = sessionStorage.getItem("gateway")
        let url = _that.ports.dataLook.settingList.settingBlockList
        let askData = {
          sn: gateway,
        }
        this.http.get(url,askData, res => {
          console.log("systemTagListAll",res)
          if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
            _that.homeTableDatas = res.data
            let arry = []
            for(let i = 0;i<_that.homeTableDatas.length;++i){
              if (_that.homeTableDatas[i].whetherCheck) {
                arry.push(_that.homeTableDatas[i])
              }
            }
            _that.toggleSelection(arry)
            _that.askSystemTags()
          }else{
            _that.$message('列表获取失败!');
          }
        })
      },
      submitAddCustomValue: function() {
        if (!this.addCustomForm.inputName || !this.addCustomForm.inputValue){
          this.$message("请输入")
          return
        }
        let _that = this
        let gateway = sessionStorage.getItem("gateway")
        let url = _that.ports.dataLook.add.customAdd
        let askData = {
          sn: gateway,
          inputName: this.addCustomForm.inputName,
          inputValue: this.addCustomForm.inputValue
        }
        this.http.post(url,askData, res => {
          if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
            _that.addDialogShow = false
            _that.askSystemTagsAll()
          }else{
            _that.$message('新增失败!');
          }
        })
      },
      deleteCustomTag: function(item) {
        let _that = this
        let url = _that.ports.dataLook.delete.customDelete
        let askData = {
          id: item.id
        }
        this.http.postForm(url,askData, res => {
          if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
            _that.addDialogShow = false
            _that.askSystemTagsAll()
          }else{
            _that.$message('删除失败!');
          }
        })
      },
      fixCustomTag: function(item) {
        let _that = this
        let url = _that.ports.dataLook.fix.customFix2
        let gateway = sessionStorage.getItem("gateway")
        let askData = {
          customizeId: item.customizeId,
          sn: gateway,
          inputValue: item.inputValue
        }
        this.http.postForm(url,askData, res => {
          if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
            _that.$message('修改成功!');
            _that.askSystemTagsAll()
          }else{
            _that.$message('修改失败!');
          }
        })
      },
      customBind: function(item){
        this.settingType = 5
        this.selectItem = item
        if (this.homeConfigDialogShow){
          this.homeConfigDialogShow = false
        } else{
          this.homeConfigDialogShow = true
        }
        this.askCustomBindTags()
      },
      fixSettingTagValue:function(item) {
        let _that = this
        let url = _that.ports.dataLook.fix.settingFix
        let gateway = sessionStorage.getItem("gateway")
        let askData = {
          id: item.id,
          sn: gateway,
          inputValue: item.inputValue
        }
        this.http.postForm(url,askData, res => {
          if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
            _that.$message('修改成功!');
            _that.askSystemTagsAll()
          }else{
            _that.$message('修改失败!');
          }
        })
      },
      askMyControlTags: function() {
        let _that = this
        let gateway = sessionStorage.getItem("gateway")
        let url = _that.ports.dataLook.myTags.controlTags
        let askData = {
          sn: gateway,
          type: 0
        }
        this.http.get(url,askData, res => {
          console.log("controlTagList",res)
          if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
            if (res.data && res.data.notUrgentList && res.data.notUrgentList.length>_that.systemShowLength){
              _that.controlTags.notUrgentList = res.data.notUrgentList.slice(0,_that.systemShowLength)
            } else{
              _that.controlTags.notUrgentList = res.data.notUrgentList
            }
            if (res.data && res.data.urgentList && res.data.urgentList.length>_that.systemShowLength){
              _that.controlTags.urgentList = res.data.urgentList.slice(0,_that.systemShowLength)
            } else{
              _that.controlTags.urgentList = res.data.urgentList
            }
          }else{
            _that.$message('列表获取失败!');
          }
        })
      },
      askControlNotUrgentTagsAll: function() {
        let _that = this
        let gateway = sessionStorage.getItem("gateway")
        let url = _that.ports.dataLook.settingList.controlUnurgentList
        let askData = {
          sn: gateway,
        }
        this.http.get(url,askData, res => {
          console.log("controlTagListAll",res)
          if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
            _that.homeTableDatas = res.data

            let arry = []
            for(let i = 0;i<_that.homeTableDatas.length;++i){
              if (_that.homeTableDatas[i].whetherCheck) {
                arry.push(_that.homeTableDatas[i])
              }
            }
            _that.toggleSelection(arry)
          }else{
            _that.$message('列表获取失败!');
          }
        })
      },
      askControlUrgentTagsAll: function() {
        let _that = this
        let gateway = sessionStorage.getItem("gateway")
        let url = _that.ports.dataLook.settingList.controlUrgentList
        let askData = {
          sn: gateway,
        }
        this.http.get(url,askData, res => {
          if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
            _that.homeTableDatas = res.data
            let arry = []
            for(let i = 0;i<_that.homeTableDatas.length;++i){
              if (_that.homeTableDatas[i].whetherCheck) {
                arry.push(_that.homeTableDatas[i])
              }
            }
            _that.toggleSelection(arry)
          }else{
            _that.$message('列表获取失败!');
          }
        })
      },
      onLogicChang: function($event,type,item) {
        let _that = this
        let inputValue = $event ? 1.0 : 0.0
        // _that.controlDialogLoading = true

        let gateway = sessionStorage.getItem("gateway")
        let url = _that.ports.dataLook.fix.controlFix
        let askData = {
          id: item.id,
          sn: gateway,
          inputValue: inputValue,
          whetherUrgent: type
        }
        try {
          this.http.postForm(url,askData, res => {
            if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
              _that.$message('ok!');
            }else{
              _that.$message('error!');
            }
            // _that.controlDialogLoading = false
            _that.askMyControlTags()
          })
        }finally {
          // _that.askMyControlTags()
        }

      },
      onUrgencyChang: function($event,type,item) {
        item.inputValue = $event
        let _that = this
        let gateway = sessionStorage.getItem("gateway")
        let url = _that.ports.dataLook.fix.controlFix
        let askData = {
          id: item.id,
          sn: gateway,
          inputValue: item.inputValue,
          whetherUrgent: type
        }
        try {
          this.http.postForm(url,askData, res => {
            if(!_that.validateGlobal.isEmpty(res) && res.code == 200){
              _that.$message('ok!');
            }else{
              _that.$message('error!');
            }
            // _that.askMyControlTags()
          })
        }finally {
          _that.askMyControlTags()
        }
      }
    }
  }
</script>

<style lang="less">

  #company-container {

    .el-button{
      float: right; padding: 6px 6px;
    }

    > .el-card{
      margin: 20px 20px 0 20px;
      height: 820px;

      .box-card-content{
        justify-content: start;
        flex-wrap: wrap;
        align-items: center;

        > .el-col{
          width: 194px;
          height: 100px;
          border: 1px solid lightgrey;
          margin-bottom: 20px;
          margin-right: 10px;
          border-radius: 10px;
          > :first-child.el-row{
            justify-content: start;
            align-items: center;
          }
          > :nth-child(2){
            justify-content: center;
            align-items: center;
            font-size: 20px;
            margin-top: 10px;
          }
          > :nth-child(3){
            justify-content: center;
            align-items: center;
            margin-top: 20px;
          }
        }
      }
    }

    .el-dialog{
      width: 1400px;
      height: 700px;

      .custom-dialog-content,.setting-dialog-content{

        .custom-layout{
          max-height: 600px;
          justify-content: start;
          flex-wrap: wrap;
          align-items: center;
          .el-col{
            width: 158px;
            height: 104px;
            border: 1px solid lightgrey;
            margin-bottom: 20px;
            margin-right: 10px;
            border-radius: 10px;

            >.el-row{
              justify-content: center;
              align-items: center;
              margin-top: 8px;
            }
          }
        }

        .el-input__inner {
          /* -webkit-appearance: none; */
          height: 20px;
          line-height: 20px;
          font-size: 12px;
        }

        .el-input {
          width: 92px;
        }
      }

      .control-dialog-content{
        width: 100%;
        >.el-row{
          height: 300px;
          .el-card{
            height: 290px;
          }
        }

        .logic-control,.urgency-control{
          justify-content: start;
          flex-wrap: wrap;
          align-items: center;

          .el-col{
            width: 120px;
            height: 90px;
            border: 1px solid lightgrey;
            margin-bottom: 20px;
            margin-right: 10px;
            border-radius: 10px;

            >.el-row{
              justify-content: center;
              align-items: center;
              margin-top: 8px;

              .el-select{
                width: 100px;
                height: 50px;
              }

              .el-input__inner {
                height: 40px;
                line-height: 40px;
                font-size: 12px;
              }

              .el-input {
                width: 100px;
              }
            }
          }
        }
        .el-input__inner {
          /* -webkit-appearance: none; */
          height: 20px;
          line-height: 20px;
          font-size: 12px;
        }

        .el-input {
          width: 72px;
        }
      }

      .add-dialog-content{

        .el-input__inner {
          /* -webkit-appearance: none; */
          height: 40px;
          width: 200px;
          line-height: 40px;
          font-size: 14px;
        }

        .el-input {
          width: 220px;
        }
      }
    }

  }

</style>

